package com.chlp.core.framework.config;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @author ChenLiPeng
 * @date 2020/3/29 16:54
 */
@Configuration
public class WebMvcConfig implements WebMvcConfigurer {

	/**
	 * 添加静态资源文件，外部可以直接访问地址
	 */
	@Override
	public void addResourceHandlers(ResourceHandlerRegistry registry) {
		//需要配置1：----------- 需要告知系统，这是要被当成静态文件的！
		//第一个方法设置访问路径前缀，第二个方法设置资源路径
		registry.addResourceHandler("/static/**").addResourceLocations("classpath:/static/");
		registry.addResourceHandler("/resources/**").addResourceLocations("classpath:/resources/");
	}

	@Override
	public void addViewControllers(ViewControllerRegistry registry) {
		//registry.addViewController("/error/404").setViewName("/admin/page_error/error_404.html");
	}
}
